<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>实用的js方案</title>
</head>

<body>
    <p id="demo"></p>
    <script>
        var w = window.innerWidth
            || document.documentElement.clientWidth
            || document.body.clientWidth;
        var h = window.innerHeight
            || document.documentElement.clientHeight
            || document.body.clientHeight;
        x = document.getElementById("demo");
        x.innerHTML = "浏览器window宽度: " + w + ", 高度: " + h + "。"
    </script>   
</body>

</html>